#include <iostream>
#include <vector>
#include <memory>

// -------------------- Monster 类层次 --------------------

// 抽象基类：Monster
class Monster {
public:
    virtual Monster* clone() const = 0; // 克隆方法
    virtual void customize(int health, int attack) = 0; // 定制方法
    virtual void display() const = 0; // 显示怪物信息
    virtual ~Monster() {}
};

// 具体类：Goblin
class Goblin : public Monster {
private:
    int health;
    int attack;
public:
    Goblin(int h = 50, int a = 15) : health(h), attack(a) {}

    // 实现克隆方法
    Monster* clone() const override {
        return new Goblin(*this);
    }

    // 实现定制方法
    void customize(int h, int a) override {
        health = h;
        attack = a;
    }

    // 显示怪物信息
    void display() const override {
        std::cout << "Goblin - Health: " << health << ", Attack: " << attack << "\n";
    }
};

// 具体类：Orc
class Orc : public Monster {
private:
    int health;
    int attack;
public:
    Orc(int h = 80, int a = 25) : health(h), attack(a) {}

    // 实现克隆方法
    Monster* clone() const override {
        return new Orc(*this);
    }

    // 实现定制方法
    void customize(int h, int a) override {
        health = h;
        attack = a;
    }

    // 显示怪物信息
    void display() const override {
        std::cout << "Orc - Health: " << health << ", Attack: " << attack << "\n";
    }
};

// 具体类：Dragon
class Dragon : public Monster {
private:
    int health;
    int attack;
public:
    Dragon(int h = 200, int a = 50) : health(h), attack(a) {}

    // 实现克隆方法
    Monster* clone() const override {
        return new Dragon(*this);
    }

    // 实现定制方法
    void customize(int h, int a) override {
        health = h;
        attack = a;
    }

    // 显示怪物信息
    void display() const override {
        std::cout << "Dragon - Health: " << health << ", Attack: " << attack << "\n";
    }
};

// -------------------- 测试主函数 --------------------

int main() {
    // 创建原始怪物
    Goblin* originalGoblin = new Goblin();
    Orc* originalOrc = new Orc();
    Dragon* originalDragon = new Dragon();

    std::cout << "Original Monsters:\n";
    originalGoblin->display();
    originalOrc->display();
    originalDragon->display();
    std::cout << "-------------------------\n";

    // 创建克隆怪物
    Monster* clonedGoblin = originalGoblin->clone();
    Monster* clonedOrc = originalOrc->clone();
    Monster* clonedDragon = originalDragon->clone();

    // 定制克隆怪物
    clonedGoblin->customize(60, 20);
    clonedOrc->customize(90, 30);
    clonedDragon->customize(250, 70);

    std::cout << "Cloned and Customized Monsters:\n";
    clonedGoblin->display();
    clonedOrc->display();
    clonedDragon->display();
    std::cout << "-------------------------\n";

    // 显示原始怪物以确保它们未被修改
    std::cout << "Original Monsters After Cloning:\n";
    originalGoblin->display();
    originalOrc->display();
    originalDragon->display();
    std::cout << "-------------------------\n";

    // 使用智能指针管理内存（可选）
    // 这里继续使用手动管理内存以保持与用户示例的一致性
    // 如果希望使用智能指针，可以替换为std::unique_ptr或std::shared_ptr

    // 释放内存
    delete originalGoblin;
    delete originalOrc;
    delete originalDragon;

    delete clonedGoblin;
    delete clonedOrc;
    delete clonedDragon;

    return 0;
}
